<%--
  Created by IntelliJ IDEA.
  User: 28267
  Date: 2021/11/22
  Time: 17:03
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>登录页面</title>
</head>
<body>
<%
// 判断是否有保存的Cookie，有，勾选，没有，不勾选
    Cookie[] cookies = request.getCookies();
    if (cookies!=null){
        for (Cookie c:cookies){
            // 获取指定的Cookie
            if ("username".equals(c.getName())){
                pageContext.setAttribute("username",c.getValue());
            }
            if ("password".equals(c.getName())){
                pageContext.setAttribute("password",c.getValue());
            }
        }
    }
%>
<form action="login">
    <table align="center">
        <tr>
            <td>账号：</td>
            <td><input type="text" name="username" value="${username}"></td>
        </tr>
        <tr>
            <td>密码：</td>
            <td><input type="password" name="password" value="${password}"></td>
        </tr>
        <tr>
            <td><input type="checkbox" value="checkOn" name="save" <c:if test="${!empty username}">checked</c:if> /> 记住账号和密码 <br><br></td>
        </tr>
        <tr>
            <td colspan="2"><input type="submit" value="登录"></td>
        </tr>
    </table>
<%--    账号:<input type="text" name="username" value="${username}"/> <br/> <br/>--%>
<%--    密码:<input type="password" name="password" value="${password}"/> <br/><br/>--%>
<%--    <input type="checkbox" value="checkOn" name="save" <c:if test="${!empty username}">checked</c:if> /> 记住账号和密码 <br><br>--%>
<%--    <input type="submit" value="登录"/>--%>
</form>
</body>
</html>
